home *** CD-ROM | disk | FTP | other *** search
- /*$Id: ImpFac.cpp 1.1 1996/08/06 18:41:04 DAMIEN Exp $*/
-
- #ifndef __IMPFAC__
- #include "ImpFac.h"
- #endif
-
- #ifndef __COMIMP__
- #include "COMImp.h"
- #endif
-
- #ifndef __IMPDLL__
- #include "ImpDll.h"
- #endif
-
-
- // ***** ClassFactory *****
-
- EasyImporterClassFactory::EasyImporterClassFactory() {
- m_cRef=0L; // just created so no reference used
- return;
- }
-
-
- EasyImporterClassFactory::~EasyImporterClassFactory() {
- return;
- }
-
- // IUnknown methods of EasyImporterClassFactory
- STDMETHODIMP EasyImporterClassFactory::QueryInterface(REFIID riid, LPVOID* ppv) {
- *ppv=NULL;
-
- if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
- *ppv=(LPVOID)this;
-
- if (*ppv!=NULL) {
- ((LPUNKNOWN)*ppv)->AddRef(); // Add reference if we give a pointer
- return NOERROR;
- }
- else {
- return ResultFromScode(E_NOINTERFACE);
- }
- }
-
-
- STDMETHODIMP_(ULONG) EasyImporterClassFactory::AddRef() {
- return ++m_cRef;
- }
-
-
- STDMETHODIMP_(ULONG) EasyImporterClassFactory::Release() {
- ULONG UnreleaseRef;
-
- UnreleaseRef=--m_cRef;
-
- if (m_cRef == 0)
- delete this; // No reference left, so delete the EasyImporterClassFactory
-
- return UnreleaseRef;
- }
-
- /*
- * EasyImporterClassFactory::CreateInstance
- *
- * Parameters:
- * pUnkOuter LPUNKNOWN to the controlling IUnknown if we are
- * being used in an aggregation.
- * riid REFIID identifying the interface the caller
- * desires to have for the new object.
- * ppvObj LPVOID FAR* in which to store the desired
- * interface pointer for the new object.
- *
- * Return Value:
- * HRESULT NOERROR if successful, otherwise E_NOINTERFACE
- * if we cannot support the requested interface.
- */
-
- STDMETHODIMP EasyImporterClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppvObj) {
- TEasyImporter* pObj = NULL;
- HRESULT hr;
-
- *ppvObj = NULL;
- hr = ResultFromScode(E_OUTOFMEMORY);
-
- //Verify that a controlling unknown asks for IUnknown
- if (pUnkOuter && !IsEqualIID(riid, IID_IUnknown))
- return ResultFromScode(E_NOINTERFACE);
-
- //Create the object passing function to notify on destruction.
- if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_I3DExImportFilter))
- pObj = new TEasyImporter;
- else
- return ResultFromScode(E_NOINTERFACE);
-
- hr=pObj->QueryInterface(IID_I3DExImportFilter, ppvObj);
-
- //Kill the object if initial creation failed.
- if (FAILED(hr))
- delete pObj;
- else
- global_count_Obj++;
-
- return hr;
- }
-
-
- /*
- * EasyImporterClassFactory::LockServer
- *
- * Purpose:
- * Increments or decrements the lock count of the DLL. If the
- * lock count goes to zero and there are no objects, the DLL
- * is allowed to unload. See DllCanUnloadNow in "atmosdll.cpp".
- *
- * Parameters:
- * fLock BOOL specifying whether to increment or
- * decrement the lock count.
- *
- * Return Value:
- * HRESULT NOERROR always.
- */
-
- STDMETHODIMP EasyImporterClassFactory::LockServer(BOOL fLock) {
- if (fLock)
- global_count_Lock++;
- else
- global_count_Lock--;
-
- return NOERROR;
- }
-
-